package com.ljm.mapper;

import com.ljm.entity.UserEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ljm.entity.vo.pathVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author song
 * @since 2021-05-18
 */
@Mapper
@Component
public interface UserMapper extends BaseMapper<UserEntity> {

    @Select("<script>" +
            "select  * from user as a, role as b, user_role as c, piece_detail as d, jurisdiction as e\n" +
            "    WHERE  a.userid=c.userid and b.roleid = c.roleid and e.piece_detail =d.piece_detailid\n" +
            "    and e.roleid=b.roleid\n" +
            "    and a.userid=#{userid} \n" +
            "    and d.type= 1\n" +
            "    group by piecename"+
            "</script>")

    List<pathVo>  getbyname(@Param("userid") Integer userid);
    @Select("<script>" +
          "select * from user as a, role as b, user_role as c, piece_detail as d, jurisdiction as e\n" +
            "WHERE a.userid=c.userid and b.roleid = c.roleid and e.roleid=c.roleid and e.roleid=b.roleid and e.piece_detail =d.piece_detailid\n" +
            "and a.userid=#{userid}\n" +
            "group by perms"+
            "</script>")

    List<pathVo> getbynameTwo(@Param("userid")Integer userid);


@Select("<script>" +
        "select perms from user as a, role as b, user_role as c, piece_detail as d, jurisdiction as e\n" +
        "WHERE a.userid=c.userid and b.roleid = c.roleid and e.roleid=c.roleid and e.roleid=b.roleid and e.piece_detail =d.piece_detailid\n" +
        "and a.userid=#{userid}\n" +
        "and d.type=2\n" +
        "group by perms" +
        "</script>")
    List<String> getUserAuthorityInfo(Integer userId);
}
